Imports EntityLayer
Imports BusinessLayer

Partial Class ListaOrdenCompra
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            Call MostrarOrdenes()
        End If
    End Sub

    Protected Sub gvwOrdenes_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gvwOrdenes.RowCommand
        Try
            Dim index As Integer = Integer.Parse(e.CommandArgument.ToString())
            Dim row As GridViewRow = gvwOrdenes.Rows(index)
            Dim key As DataKey = gvwOrdenes.DataKeys(row.RowIndex)


            'If e.CommandName = "Prod" Then
            '    MostrarProductos((key(0).ToString()))
            'End If
            If e.CommandName = "Edt" Then
                EditarSolicitud((key(0).ToString()))
            End If
            If e.CommandName = "Del" Then
                EliminarSolicitud((key(0).ToString()))
            End If
        Catch ex As Exception

        End Try
    End Sub


    Private Sub EliminarSolicitud(ByVal strCodigo As String)
        OrdenCompraBL.Eliminar(CInt(strCodigo))
        gvwOrdenes.DataSource = OrdenCompraBL.ListarOrdenes
        gvwOrdenes.DataBind()
        'lblProducto.Text = ""
        ' dgListaProducto.DataSource = Nothing
        ' dgListaProducto.DataBind()
    End Sub

    Private Sub EditarSolicitud(ByVal strCodigo As String)
        Response.Redirect("OrdenCompra.aspx?strCodigo=" & strCodigo)
    End Sub

    Private Sub MostrarOrdenes()
        gvwOrdenes.DataSource = OrdenCompraBL.ListarOrdenes
        gvwOrdenes.DataBind()
    End Sub
End Class
